<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #div1{
            width: 300px;
            height: 300px;
            background-color: black;
            color: white;
        }
    </style>
</head>
<body>
    <p>属性名：<input type="text" value=""></p>
    <p>属性值：<input type="text" value=""></p>
    <button>确定</button> <button>重置</button>
    <div id="div1">在上方输入框输入"属性名"及"属性值"，点击确定按钮查看效果。</div>
</body>
<script>
    function style (ele,name,value){
        ele.style[name] = value
    }
    let but = document.getElementsByTagName('button')
    let input = document.getElementsByTagName('input')
    let box = document.getElementById('div1')
    but[0].onclick = function (){
        style(box,input[0].value,input[1].value)
    }
    but[1].onclick = function (){
        style(box,'background','black')
    }
</script>
</html>